home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AppleScript - The Beta Release
/
AppleScript - The Beta Release.iso
/
Development Tools
/
Interfaces
/
PInterfaces
/
OSA.p
< prev
Wrap
Text File
|
1992-11-14
|
18KB
|
573 lines
{
////////////////////////////////////////////////////////////////////////////////
// OPEN SCRIPTING ARCHITECTURE: Client Interface
////////////////////////////////////////////////////////////////////////////////
// Copyright © 1992 Apple Computer, Inc. All rights reserved.
// Authors: Jens Alfke, William Cook, Donn Denman, and Warren Harris
////////////////////////////////////////////////////////////////////////////////
// This interface defines what it means to be a "scripting component."
// Scripting components allow "scripts" to be loaded and executed. This
// interface does not define the way in which a particular scripting
// component's scripts are editing and debugged.
////////////////////////////////////////////////////////////////////////////////
}
{$IFC UNDEFINED UsingIncludes}
{$SETC UsingIncludes := 0}
{$ENDC}
{$IFC NOT UsingIncludes}
UNIT OSA;
INTERFACE
{$ENDC}
{$IFC UNDEFINED UsingOSA}
{$SETC UsingOSA := 1}
{$I+}
{$SETC OSAIncludes := UsingIncludes}
{$SETC UsingIncludes := 1}
{$IFC UNDEFINED UsingAppleEvents}
{$I $$Shell(PInterfaces)AppleEvents.p}
{$ENDC}
{$IFC UNDEFINED UsingComponents}
{$I $$Shell(PInterfaces)Components.p}
{$ENDC}
{$SETC UsingIncludes := OSAIncludes}
{ Types and Constants }
CONST
kOSAComponentType = 'osa ';
kOSAGenericScriptingComponentSubtype = 'scpt';
TYPE
OSAID = LONGINT;
OSAError = ComponentResult;
CONST
kOSANullScript = 0;
kOSANullMode = 0;
kOSAModeNull = 0;
kOSASuite = 'ascr';
kOSARecordedText = 'recd';
kOSAScriptResourceType = kOSAGenericScriptingComponentSubtype;
typeOSAGenericStorage = kOSAScriptResourceType;
{ Error Codes }
errOSACorruptData = -1702; { Same as errAECorruptData }
errOSASystemError = -1750;
errOSAInvalidID = -1751;
errOSABadStorageType = -1752;
errOSAScriptError = -1753;
errOSABadSelector = -1754;
errOSAInvalidAccess = -1755;
errOSASourceNotAvailable = -1756;
errOSARecordingIsAlreadyOn = -1732;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Interface Descriptions
////////////////////////////////////////////////////////////////////////////////
// The OSA Interface is broken down into a required interface, and several
// optional interfaces to support additional functionality. A given scripting
// component may choose to support only some of the optional interfaces in
// addition to the basic interface. The OSA Component Flags may be used to
// query the Component Manager to find a scripting component with a particular
// capability, or determine if a particular scripting component supports a
// particular capability.
////////////////////////////////////////////////////////////////////////////////
}
{ OSA Component Flags }
kOSASupportsCompiling = 2**1;
kOSASupportsGetSource = 2**2;
kOSASupportsAECoercion = 2**3;
kOSASupportsAESending = 2**4;
kOSASupportsRecording = 2**5;
kOSASupportsConvenience = 2**6;
kOSASupportsDialects = 2**7;
kOSASupportsEventHandling = 2**8;
{ Component Selectors }
{ Basic Scripting: }
kOSASelectLoad = $0001;
kOSASelectStore = $0002;
kOSASelectExecute = $0003;
kOSASelectDisplay = $0004;
kOSASelectScriptError = $0005;
kOSASelectDispose = $0006;
kOSASelectSetScriptInfo = $0007;
kOSASelectGetScriptInfo = $0008;
kOSASelectSetActiveProc = $0009;
kOSASelectGetActiveProc = $000A;
{ Compiling: }
kOSASelectScriptingComponentName = $0102;
kOSASelectCompile = $0103;
kOSASelectCopyID = $0104;
{ GetSource: }
kOSASelectGetSource = $0201;
{ AECoercion: }
kOSASelectCoerceFromDesc = $0301;
kOSASelectCoerceToDesc = $0302;
{ AESending: }
kOSASelectSetSendProc = $0401;
kOSASelectGetSendProc = $0402;
kOSASelectSetCreateProc = $0403;
kOSASelectGetCreateProc = $0404;
kOSASelectSetDefaultTarget = $0405;
{ Recording: }
kOSASelectStartRecording = $0501;
kOSASelectStopRecording = $0502;
{ Convenience:
kOSASelectLoadExecute = $0601;
kOSASelectCompileExecute = $0602;
kOSASelectDoScript = $0603;
{ Dialects: }
kOSASelectSetCurrentDialect = $0701;
kOSASelectGetCurrentDialect = $0702;
kOSASelectAvailableDialects = $0703;
{ Event Handling: }
kOSASelectSetResumeDispatchProc = $0801;
kOSASelectGetResumeDispatchProc = $0802;
kOSASelectExecuteEvent = $0803;
kOSASelectDoEvent = $0804;
kOSASelectMakeContext = $0805;
kOSASelectComponentSpecificStart = $1001;
{ scripting component specific selectors are added beginning with this
value }
{ Mode Flags }
kOSAModePreventGetSource = $00000001;
kOSAModeNeverInteract = kAENeverInteract;
kOSAModeCanInteract = kAECanInteract;
kOSAModeAlwaysInteract = kAEAlwaysInteract;
kOSAModeDontReconnect = kAEDontReconnect;
kOSAModeCantSwitchLayer = $00000040;
kOSAModeDoRecord = $00001000;
kOSAModeCompileIntoContext = $00000002;
kOSAModeAugmentContext = $00000004;
kOSAModeDisplayForHumans = $00000008;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Basic Scripting Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components must at least support the Basic Scripting interface.
////////////////////////////////////////////////////////////////////////////////
}
{ Loading and Storing Scripts }
FUNCTION
OSALoad(scriptingComponent : ComponentInstance;
scriptData : AEDesc;
modeFlags : LONGINT;
VAR resultingScriptID : OSAID)
: OSAError;
INLINE $2F3C, $000C, $0001, $7000, $A82A;
FUNCTION
OSAStore(scriptingComponent : ComponentInstance;
scriptID : OSAID;
desiredType : DescType;
modeFlags : LONGINT;
VAR resultingScriptData : AEDesc)
: OSAError;
INLINE $2F3C, $000C, $0002, $7000, $A82A;
{ Executing Scripts }
FUNCTION
OSAExecute(scriptingComponent : ComponentInstance;
compiledScriptID : OSAID;
contextID : OSAID;
modeFlags : LONGINT;
VAR resultingScriptValueID : OSAID)
: OSAError;
INLINE $2F3C, $0010, $0003, $7000, $A82A;
{ Displaying Results }
FUNCTION
OSADisplay(scriptingComponent : ComponentInstance;
scriptValueID : OSAID;
desiredType : DescType;
modeFlags : LONGINT;
VAR resultingText : AEDesc)
: OSAError;
INLINE $2F3C, $0010, $0004, $7000, $A82A;
{ Getting Error Information }
FUNCTION
OSAScriptError(scriptingComponent : ComponentInstance;
selector : OSType;
desiredType : DescType;
VAR resultingErrorDescription : AEDesc)
: OSAError;
INLINE $2F3C, $000C, $0005, $7000, $A82A;
CONST { OSAScriptError selectors: }
kOSAErrorNumber = 'errn';
kOSAErrorMessage = 'errs';
kOSAErrorBriefMessage = 'errb';
kOSAErrorApp = 'erap';
kOSAErrorPartialResult = 'ptlr';
kOSAErrorOffendingObject = 'erob';
kOSAErrorRange = 'erng';
{ text ranges: }
typeOSAErrorRange = 'erng';
keySourceStart = 'srcs';
keySourceEnd = 'srce';
{ Disposing Script IDs }
FUNCTION
OSADispose(scriptingComponent : ComponentInstance;
scriptID : OSAID)
: OSAError;
INLINE $2F3C, $0004, $0006, $7000, $A82A;
{ Getting and Setting Script Information }
FUNCTION
OSASetScriptInfo(scriptingComponent : ComponentInstance;
scriptID : OSAID;
selector : OSType;
value : LONGINT)
: OSAError;
INLINE $2F3C, $000C, $0007, $7000, $A82A;
FUNCTION
OSAGetScriptInfo(scriptingComponent : ComponentInstance;
scriptID : OSAID;
selector : OSType;
VAR result : LONGINT)
: OSAError;
INLINE $2F3C, $000C, $0008, $7000, $A82A;
CONST { selectors }
kOSAScriptIsModified = 'modi';
kOSAScriptIsBeingEdited = 'edit';
kOSAScriptIsBeingRecorded = 'recd';
kOSAScriptIsTypeCompiledScript = 'cscr';
kOSAScriptIsTypeScriptValue = 'valu';
kOSAScriptIsTypeScriptContext = 'cntx';
kOSAScriptBestType = 'best';
{ Manipulating the ActiveProc }
TYPE
OSAActiveProcPtr = ProcPtr;
FUNCTION
OSASetActiveProc(scriptingComponent : ComponentInstance;
activeProc : OSAActiveProcPtr;
refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0009, $7000, $A82A;
FUNCTION
OSAGetActiveProc(scriptingComponent : ComponentInstance;
VAR activeProc : OSAActiveProcPtr;
VAR refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $000A, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional Compiling Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the Compiling interface have the
// kOSASupportsCompiling bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
FUNCTION
OSAScriptingComponentName(
scriptingComponent : ComponentInstance;
VAR resultingScriptingComponentName : AEDesc)
: OSAError;
INLINE $2F3C, $0004, $0102, $7000, $A82A;
FUNCTION
OSACompile(scriptingComponent : ComponentInstance;
sourceData : AEDesc;
modeFlags : LONGINT;
VAR resultingCompiledScriptID : OSAID)
: OSAError;
INLINE $2F3C, $000C, $0103, $7000, $A82A;
FUNCTION
OSACopyID(scriptingComponent : ComponentInstance;
fromID : OSAID;
VAR toID : OSAID)
: OSAError;
INLINE $2F3C, $0008, $0104, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional GetSource Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the GetSource interface have the
// kOSASupportsGetSource bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
FUNCTION
OSAGetSource(scriptingComponent : ComponentInstance;
scriptID : OSAID;
desiredType : DescType;
VAR resultingSourceData : AEDesc)
: OSAError;
INLINE $2F3C, $000C, $0201, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional AECoercion Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the AECoercion interface have the
// kOSASupportsGetSource bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
FUNCTION
OSACoerceFromDesc(scriptingComponent : ComponentInstance;
scriptData : AEDesc;
modeFlags : LONGINT;
VAR resultingScriptValueID : OSAID)
: OSAError;
INLINE $2F3C, $000C, $0301, $7000, $A82A;
FUNCTION
OSACoerceToDesc(scriptingComponent : ComponentInstance;
scriptValueID : OSAID;
desiredType : DescType;
modeFlags : LONGINT;
VAR result : AEDesc)
: OSAError;
INLINE $2F3C, $0010, $0302, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional AESending Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the AESending interface have the
// kOSASupportsAESending bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
TYPE
AESendProcPtr = ProcPtr;
AECreateAppleEventProcPtr = ProcPtr;
{ The first two proc pointers have the following interfaces
taken from AppleEvents.p
FUNCTION AECreateAppleEvent(theAEEventClass: AEEventClass;
theAEEventID: AEEventID;
target: AEAddressDesc;
returnID: INTEGER;
transactionID: LONGINT;
VAR result: AppleEvent): OSErr;
FUNCTION AESend(theAppleEvent: AppleEvent;
VAR reply: AppleEvent;
sendMode: AESendMode;
sendPriority: AESendPriority;
timeOutInTicks: LONGINT;
idleProc: IdleProcPtr;
filterProc: EventFilterProcPtr): OSErr;
FUNCTION OSAActive(): OSErr;
}
FUNCTION
OSASetSendProc(scriptingComponent : ComponentInstance;
sendProc : AESendProcPtr;
refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0401, $7000, $A82A;
FUNCTION
OSAGetSendProc(scriptingComponent : ComponentInstance;
VAR sendProc : AESendProcPtr;
VAR refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0402, $7000, $A82A;
FUNCTION
OSASetCreateProc(scriptSystem : ComponentInstance;
createProc : AECreateAppleEventProcPtr;
refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0403, $7000, $A82A;
FUNCTION
OSAGetCreateProc(scriptSystem : ComponentInstance;
VAR createProc : AECreateAppleEventProcPtr;
VAR refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0404, $7000, $A82A;
FUNCTION
OSASetDefaultTarget(scriptSystem : ComponentInstance;
target : AEAddressDesc)
: OSAError;
INLINE $2F3C, $0004, $0405, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional Recording Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the Recording interface have the
// kOSASupportsRecording bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
FUNCTION
OSAStartRecording(scriptingComponent : ComponentInstance;
VAR compiledScriptToModifyID : OSAID)
: OSAError;
INLINE $2F3C, $0004, $0501, $7000, $A82A;
FUNCTION
OSAStopRecording(scriptingComponent : ComponentInstance;
compiledScriptID : OSAID)
: OSAError;
INLINE $2F3C, $0004, $0502, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional Convenience Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the Convenience interface have the
// kOSASupportsConvenience bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
FUNCTION
OSALoadExecute(scriptingComponent : ComponentInstance;
scriptData : AEDesc;
contextID : OSAID;
modeFlags : LONGINT;
VAR resultingScriptValueID : OSAID)
: OSAError;
INLINE $2F3C, $0010, $0601, $7000, $A82A;
FUNCTION
OSACompileExecute(scriptingComponent : ComponentInstance;
sourceData : AEDesc;
contextID : OSAID;
modeFlags : LONGINT;
VAR resultingScriptValueID : OSAID)
: OSAError;
INLINE $2F3C, $0010, $0602, $7000, $A82A;
FUNCTION
OSADoScript(scriptingComponent : ComponentInstance;
sourceData : AEDesc;
contextID : OSAID;
desiredType : DescType;
modeFlags : LONGINT;
VAR resultingText : AEDesc)
: OSAError;
INLINE $2F3C, $0014, $0603, $7000, $A82A;
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional Dialects Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the Dialects interface have the
// kOSASupportsDialects bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
FUNCTION
OSASetCurrentDialect(scriptingComponent : ComponentInstance;
dialectCode : INTEGER)
: OSAError;
INLINE $2F3C, $0002, $0701, $7000, $A82A;
FUNCTION
OSAGetCurrentDialect(scriptingComponent : ComponentInstance;
VAR resultingDialectCode : INTEGER)
: OSAError;
INLINE $2F3C, $0004, $0702, $7000, $A82A;
FUNCTION
OSAAvailableDialects(scriptingComponent : ComponentInstance;
VAR resultingDialectInfoList : AEDesc)
: OSAError;
INLINE $2F3C, $0004, $0703, $7000, $A82A;
CONST
typeOSADialectInfo = 'difo';
keyOSADialectName = 'dnam';
keyOSADialectCode = 'dcod';
keyOSADialectLangCode = 'dlcd';
keyOSADialectScriptCode = 'dscd';
{
////////////////////////////////////////////////////////////////////////////////
// OSA Optional Event Handling Interface
////////////////////////////////////////////////////////////////////////////////
// Scripting components that support the Event Handling interface have the
// kOSASupportsEventHandling bit set in it's ComponentDescription.
////////////////////////////////////////////////////////////////////////////////
}
TYPE
AEHandlerProcPtr = EventHandlerProcPtr;
FUNCTION
OSASetResumeDispatchProc(scriptingComponent : ComponentInstance;
resumeDispatchProc : AEHandlerProcPtr;
refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0801, $7000, $A82A;
FUNCTION
OSAGetResumeDispatchProc(scriptingComponent : ComponentInstance;
VAR resumeDispatchProc : AEHandlerProcPtr;
VAR refCon : LONGINT)
: OSAError;
INLINE $2F3C, $0008, $0802, $7000, $A82A;
FUNCTION
OSAExecuteEvent(scriptingComponent : ComponentInstance;
theAppleEvent : AppleEvent;
contextID : OSAID;
modeFlags : LONGINT;
VAR resultingScriptValueID : OSAID)
: OSAError;
INLINE $2F3C, $0010, $0803, $7000, $A82A;
FUNCTION
OSADoEvent(scriptingComponent : ComponentInstance;
theAppleEvent : AppleEvent;
contextID : OSAID;
modeFlags : LONGINT;
VAR reply : AppleEvent)
: OSAError;
INLINE $2F3C, $0010, $0804, $7000, $A82A;
FUNCTION
OSAMakeContext(scriptingComponent : ComponentInstance;
contextName : StringPtr;
parentContext : OSAID;
VAR resultingContextID : OSAID)
: OSAError;
INLINE $2F3C, $000C, $0805, $7000, $A82A;
{$ENDC} { UsingOSA }
{$IFC NOT UsingIncludes}
END.
{$ENDC}